/****************************************************************************

 Copyright (C) 2009 Jean Pierre Charalambos. All rights reserved.

 Class contributed by: Juan Carlos León (http://code.google.com/p/maku/).

 This file is part of maku version 0.2.

 http://code.google.com/p/maku/
 email: jpcharalambosh@unal.edu.co

 This file may be used under the terms of the GNU General Public License
 versions 2.0 or 3.0 as published by the Free Software Foundation and
 appearing in the COPYING file included in the packaging of this file.

 This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

*****************************************************************************/

#include "uniform.h"

Uniform::Uniform() {
    //TODO y que del nombre
    type=0;
    size=0;
    xValue=0.0;
    yValue=0.0;
    zValue=0.0;
    wValue=0.0;
    limit=300;
}

Uniform::Uniform ( QString aName,int aValue,int aSize,int _location ) {
    name=aName;
    xValue= ( float ) aValue;
    if ( xValue>limit || xValue<-1*limit )
        xValue=0;
    size=aSize;
    type=1;
    location=_location;
}

Uniform::Uniform ( QString aName,float aValue,int aSize,int _location ) {
    name=aName;
    xValue=aValue;
    if ( xValue>limit || xValue<-1*limit )
        xValue=0;
    size=aSize;
    type=2;
    location=_location;
}

int Uniform::getValueAsInt ( int index ) {
    switch ( index ) {
    case 1:
        return ( int ) xValue;
        break;
    case 2:
        return ( int ) yValue;
        break;
    case 3:
        return ( int ) zValue;
        break;
    case 4:
        return ( int ) wValue;
        break;
    default:
        return ( int ) wValue;
        break;
        break;

    }
}

int Uniform::getLocation() {
    return location;
}

float Uniform::getValueAsFloat ( int index ) {
    switch ( index ) {
    case 1:
        return xValue;
        break;
    case 2:
        return yValue;
        break;
    case 3:
        return zValue;
        break;
    case 4:
        return wValue;
        break;
    default:
        return wValue;
        break;
    }
}

void Uniform::setIntValue ( int value,int index ) {
    switch ( index ) {
    case 1:
        xValue= ( int ) value;
        break;
    case 2:
        yValue= ( int ) value;
        break;
    case 3:
        zValue= ( int ) value;
        break;
    case 4:
        wValue= ( int ) value;
        break;
    }
}

void Uniform::setFloatValue ( float value,int index ) {
    switch ( index ) {
    case 1:
        xValue=value;
        break;
    case 2:
        yValue=value;
        break;
    case 3:
        zValue=value;
        break;
    case 4:
        wValue=value;
        break;
    }
}

int Uniform::getType() {
    return type;
}

int Uniform::getSize() {
    return size;
}

QString Uniform::getName() {
    return name;
}

void Uniform::setName ( QString aName ) {
    name=aName;
}
